package com.joysuch.wwyt.util;

import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import java.security.NoSuchAlgorithmException;

public class CipherInstance {

    private static ThreadLocal<Cipher> cipherTL =new ThreadLocal<Cipher>(){
        @Override
        protected Cipher initialValue() {
            try {
                return Cipher.getInstance("AES/CBC/NoPadding");
            }catch(Exception e){
                return null;
            }
        }
    };

    public static Cipher getInstance() throws NoSuchAlgorithmException, NoSuchPaddingException {
        return cipherTL.get();
    }
}
